const path = require('path');
const Timestamp = new Date().getTime();

function resolve(dir) {
    return path.join(__dirname, dir)
}
module.exports = {
  publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
  outputDir: 'dist',
  devServer: {
    open: true,
    host: '0.0.0.0',
    port: '8081',
    proxy: {
      '/home': {
          target: 'https://fundapi.fundvaccine.in', // 开发环境
          ws: true,
          changeOrigin: true,
          // pathRewrite: {
          //     '^/api': ''
          // }
      }
    }
  },
  filenameHashing: true, //设置打包版本号
  chainWebpack: (config) => {//设置相对路径
    config.resolve.alias
        .set('@', resolve('src'))
        .set('@vie', resolve('src/views'))
        .set('@uit', resolve('src/utils'))
        .set('@ass', resolve('src/assets'))
        .set('@com', resolve('src/components'))
    // 设置svg
    const svgRule = config.module.rule('svg')
    svgRule.uses.clear()
    svgRule
    .use('svg-sprite-loader')
    .loader('svg-sprite-loader')
    .options({
        symbolId: 'icon-[name]',
        include:['./src/icons']
    })
  },
  configureWebpack:{ // 给js配置版本号,防止浏览器js缓存不更新
    output: {
        // 输出重构【模块名称.hash值.时间戳】
        filename: `[name].[hash].${Timestamp}.js`,
        chunkFilename: `[name].[hash].${Timestamp}.js`
    },
  },
}